-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schemadiff
: better nil check validation
#15526
schemadiff
: better nil check validation
#15526
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
schemadiff
: better nil check validation
go/vt/schemadiff/diff.go
Outdated
@@ -177,7 +177,7 @@ func DiffSchemas(env *Environment, schema1 *Schema, schema2 *Schema, hints *Diff | |||
|
|||
// EntityDiffByStatement is a helper function that returns a simplified and incomplete EntityDiff based on the given SQL statement. | |||
// It is useful for testing purposes as a quick mean to wrap a statement with a diff. | |||
func EntityDiffByStatement(statement sqlparser.Statement) EntityDiff { | |||
func EntityDiffByStatement(env *Environment, statement sqlparser.Statement) EntityDiff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env
doesn't appear to be actually used in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It was due to an earlier iteration. Now removed.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #15526 +/- ##
==========================================
- Coverage 65.71% 65.70% -0.01%
==========================================
Files 1560 1560
Lines 194484 194492 +8
==========================================
- Hits 127798 127790 -8
- Misses 66686 66702 +16 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Shlomi Noach <[email protected]>
@@ -214,9 +214,16 @@ func unifiedAnnotated(from *TextualAnnotations, to *TextualAnnotations) *Textual | |||
// annotatedDiff returns the annotated representations of the from and to entities, and their unified representation. | |||
func annotatedDiff(diff EntityDiff, entityAnnotations *TextualAnnotations) (from *TextualAnnotations, to *TextualAnnotations, unified *TextualAnnotations) { | |||
fromEntity, toEntity := diff.Entities() | |||
// Handle the infamous golang interface is not-nil but underlying object is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TiL that an interface holding a nil value is not nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're in for some fun times!
Description
Quick followup to #15519, when further testing
annotations
, we getnil
reference errors. This is due to the ever unexpectedgolang
behavior of "interface is not nil but actual value is nil".This PR does better handling of
nil
interface values, and adds tests to validate.Related Issue(s)
#15519
Checklist
Deployment Notes